# 建置階段 1: 編譯應用程式
FROM golang:1.16 AS builder
WORKDIR /app
COPY . .
RUN go build -o myapp
# 建置階段 2: 建立最終容器
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/myapp .
CMD ["./myapp"]
version: '3'
services:
webapp:
image: myapp:latest
ports:
- "80:80"
database:
image: postgres:latest
environment:
POSTGRES_PASSWORD: mypassword